package cn.tedu.knows.search;

import cn.tedu.knows.search.repository.QuestionRepository;
import cn.tedu.knows.search.service.IQuestionService;
import cn.tedu.knows.search.vo.QuestionVo;
import com.github.pagehelper.PageInfo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

@SpringBootTest
public class SyncQuestion {
    @Resource
    IQuestionService questionService;
    @Test
    public void sync(){
        questionService.syncData();
    }
    @Resource
    QuestionRepository questionRepository;
    @Test
    public void getAll(){
        Iterable<QuestionVo> qs = questionRepository.findAll();
        for (QuestionVo q : qs){
            System.out.println(q);
        }
    }

    @Test
    void searchTest(){
        Page<QuestionVo> page = questionRepository.queryAllByParams(
                "java","java",11, PageRequest.of(
                        0,8
                )
        );
        for (QuestionVo vo : page){
            System.out.println(vo);
        }
    }

    @Test
    void serviceTest(){
        PageInfo<QuestionVo> pageInfo = questionService.search(
                "java","st2",1,8
        );
        for(QuestionVo vo : pageInfo.getList()){
            System.out.println(vo);
        }
    }
}
